package com.aop.test1;

import java.lang.reflect.Method;

import com.aop.test.LogInvocationHandler;

/**
 *
 * @version 1.0
 * @author hktry
 * @Email 13117011726@163.com Descriptions： Business.java Company： 浙江祥生物业服务有限公司
 * @date 2017年2月21日
 */
public class ProxyBusiness implements IBusiness, IBusiness2 {
	private LogInvocationHandler h;

	public ProxyBusiness(LogInvocationHandler h) {
		super();
		this.h = h;
	}

	@Override
	public void doSomeThing2() {
		try {
			Method method = h.target.getClass().getMethod("doSomeThing", null);
			System.out.println("aaaaa");
			h.invoke(this, method, null);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public boolean doSomeThing() {
		try {
			Method method = h.target.getClass().getMethod("doSomeThing2", null);
			System.out.println("bbbbbbb");
			return (Boolean)h.invoke(this, method, null);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

}
